package com.demo.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 验证码类型
 *
 * @author wangfengchen
 */
@Getter
public enum CaptchaTypeEnum {

  /**
   * 圆圈干扰验证码
   */
  CIRCLE("circle", "圆圈干扰验证码"),

  /**
   * 线段干扰验证码
   */
  LINE("line", "线段干扰验证码"),

  /**
   * GIF验证码
   */
  GIF("gif", "GIF验证码"),

  /**
   * 扭曲干扰验证码
   */
  SHEAR("shear", "扭曲干扰验证码");


  private final String name;

  /**
   * 描述
   */
  private final String desc;

  CaptchaTypeEnum(String name, String desc) {
    this.name = name;
    this.desc = desc;
  }

  public static CaptchaTypeEnum match(String name) {
    Optional<CaptchaTypeEnum> target = Arrays.stream(CaptchaTypeEnum.values()).filter(item -> name.equalsIgnoreCase(item.getName()))
        .findFirst();
    return target.orElse(null);
  }


}
